package com.fivebrms.view.independent.validators
{
	import org.osflash.thunderbolt.Logger;
	
	import mx.controls.Button;
	import mx.controls.CheckBox;
	import mx.controls.TextInput;
	import mx.containers.VBox;
		
    import mx.validators.Validator;
    import mx.validators.ValidationResult;
	import mx.events.FlexEvent;
	
	import com.fivebrms.model.MainModelLocator;
	
	import com.fivebrms.view.independent.FormFields;
	
    public class IndependentValidator extends Validator 
    {
		private var formFields : FormFields;
		
		//
		// grab the vo from the model locator
		//
		public var model : MainModelLocator = MainModelLocator.getInstance();
                
        private var results : Array;

        public function IndependentValidator( formFields : FormFields ) 
        {
            super();
			this.formFields = formFields;
        }
		
		//
		// run this after the button to submit the contract has occurred
		//
        override protected function doValidation(value : Object) : Array 
        {
        	//
            // Clear results Array.
            //
            results = [];
            
            Logger.info("IndependentValidator test..1.." );
            
			this.formFields.inp_contractorName.errorString = "";
			this.formFields.inp_contractorAddress.errorString = "";
			
			if
				(
					(this.formFields.inp_contractorName.text.length == 0)
				)
			{
				this.formFields.inp_contractorName.errorString = "Required Field.";
				results.push(new ValidationResult(true, "inp_contractorName", "missing", "Required Field."));
			}
			
			if
				(
					(this.formFields.inp_contractorAddress.length == 0)
				)
			{
				this.formFields.inp_contractorAddress.errorString = "Required Field.";
				results.push(new ValidationResult(true, "inp_contractorAddress", "missing", "Required Field."));
			}
			
			Logger.info("IndependentValidator test..3..");
						
            return results;
        }
 
    }
}
